$(function(){
	//城市下拉单
	$(".pull").click(function(){
        var index = $(".pull").index($(this));
		if($(".city").eq(index).is(":hidden")){
			$(".city").eq(index).slideDown();
//			index.$("span").css("background","url(../img/jianxia.png) no-repeat")
		}else{
			$(".city").eq(index).slideUp();
		}
	})
	//鼠标移上显示,移除隐藏
	$(".post").hover(function(){
		var index = $(".post").index($(this));
		$(".select").eq(index).css("display","block");
		$(".post").eq(index).css("background","#fff");
	},function(){
		$(".select").css("display","none");
		$(".post").css("background","#eee");
	})
	//鼠标选择城市，城市切换
	$(".select-top a,.select-down a").click(function(){
		var index = $(".select-top a,.select-down a").index($(this));
		$(".post>a").html($(".select-top a,.select-down a").eq(index).text());
	})

	//scroll事件
	$(".top").click(function(){
		$(window).scrollTop(0);
	})

	
	
	//无缝轮播图
	var oUl = document.getElementsByClassName("banner-ul")[0];
	var oBanner = document.getElementById("banner");
	var navlist = document.getElementsByClassName("banner-nav-ul")[0].children;
	//当前要显示的图片索引，索引从0开始，打开页面即将切换到第2张，因此索引初始值为1
	//运动会根据当前索引值，将相应的图片显示出来
	var index = 0;
	var timer = null;
	//alert(navlist.length);
	timer = setInterval(carouseFigure, 3000); //第一步，让图片自动轮播
	oBanner.onmouseover = function() {
		clearInterval(timer);
	}
	oBanner.onmouseout = function() {
		timer = setInterval(carouseFigure, 3000); //onmouseout继续，自动轮播
	}
	//点击切换轮播图
	for(var i=0;i<navlist.length;i++){
		navlist[i].oIndex = i;
		navlist[i].onclick = function(){
			//alert(1)
			for(var j=0;j<navlist.length;j++){
				navlist[j].className = "banner-nav-li";
			}
			navlist[this.oIndex].className="banner-nav-li active";
			oUl.style.left = -this.oIndex*1260+"px";
			index = this.oIndex;
		}
	}
	function carouseFigure() {
		index++;
		if (index == 9) {
			oUl.style.left = 0;
			index = 0;
		}
		//先保证下面每个小导航按钮，跟着变化，className= banner-nav-li active
		//for先清下样式
		for (var i = 0; i < navlist.length; i++) {
			navlist[i].className = "banner-nav-li";
		}
		
		startMove(oUl, {
			left: -oUl.children[0].offsetWidth * index
		}, 500, "easeIn");

		//为了无缝轮播，当全部走完一轮的时候，就会下轮开始的时候
		navlist[index >= 9 ? 0 : index].className = "banner-nav-li active";
	}
	
	
	//点击购物车
	$(".pro-info-che").click(function(){
		$(this).animate({"background-position":"-514px","background-position-y":"-291px"},300);
	})
})